<template>
  <div class="sidebar">
    <a-menu
        mode="inline"
        :selectedKeys="[currentPath]"
        style="height: 100%"
        @click="navigateTo"
    >
      <div class="logo">慈善捐赠系统</div>
      <a-menu-item key="/charity">
        <span>慈善项目</span>
      </a-menu-item>
      <a-menu-item key="/charity-org">
        <span>慈善组织</span>
      </a-menu-item>
      <a-menu-item key="/regulator">
        <span>监管机构</span>
      </a-menu-item>
      <a-menu-item key="/beneficiary">
        <span>受益人</span>
      </a-menu-item>
      <a-menu-item key="/donor">
        <span>捐赠者</span>
      </a-menu-item>
    </a-menu>
  </div>
</template>

<script>
export default {
  name: 'the-Sidebar',
  data() {
    return {
      currentPath: this.$route.path
    }
  },
  watch: {
    '$route'(to) {
      this.currentPath = to.path
    }
  },
  methods: {
    navigateTo({ key }) {
      this.$router.push(key)
    }
  }
}
</script>

<style scoped>
.sidebar {
  width: 256px; /* 增加宽度 */
  height: 100vh;
  background: #001529; /* 深色背景 */
  position: fixed;
  left: 0;
  top: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.logo {
  height: 64px;
  line-height: 64px;
  text-align: center;
  color: white;
  font-size: 20px;
  font-weight: bold;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

/* 菜单样式调整 */
:deep(.ant-menu) {
  background: #001529;
  color: rgba(255,255,255,0.65);
  font-size: 16px;
  border-right: none;
}

:deep(.ant-menu-item) {
  height: 50px;
  line-height: 50px;
  margin: 4px 0;
  padding-left: 24px !important;
}

:deep(.ant-menu-item:hover) {
  color: #fff;
}

:deep(.ant-menu-item-selected) {
  background-color: #1890ff !important;
  color: #fff;
}

:deep(.ant-menu-item::after) {
  display: none;
}
</style>